 <!DOCTYPE html>
 <html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
 </head>
 <body>
  <script>
    function Person(){}
    Person.prototype.running = function(){}
    Person.randomPerson = function(){}
    var p1 = new Person()
    p1.running()
    Person.randomPerson()


    var names = ["abc", "cba", "nba", "mba"]
    class Person1 {
      constructor(name, age) {
        this.name = name
        this.age = age
      }

      // 实例方法
      running(){}
      eating(){}
      // 类方法
      static randomPerson() {
        console.log(this)
        var randomName = names[Math.floor(Math.random() * names.length)]
        return new this(randomName, Math.floor(Math.random() * 100))
      }
    }
    var p1 = new Person1()
    p1.running()
    p1.eating()
    var randomPerson = Person1.randomPerson()
    console.log(randomPerson)
  </script>
 </body>
 </html>